home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 7536 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.5 KB  |  56 lines

  1. Newsgroups: comp.sys.amiga.programmer
  2. Path: chang.unx.sas.com!walker
  3. From: walker@chang.unx.sas.com (Doug Walker)
  4. Subject: Re: alloca() on Amiga?
  5. Sender: news@unx.sas.com (Noter of Newsworthy Events)
  6. Message-ID: <Dq26qw.6LB@unx.sas.com>
  7. Date: Thu, 18 Apr 1996 12:59:20 GMT
  8. X-Nntp-Posting-Host: chang.unx.sas.com
  9. References: <2720tdg60.alamito@marketgraph.xs4all.nl> <DpE7Ip.7or@unx.sas.com> <393brdv60.alamito@marketgraph.xs4all.nl> <4l59du$bdo@enterprise.netserv.chula.ac.th>
  10. Organization: SAS Institute Inc.
  11.  
  12. In article <4l59du$bdo@enterprise.netserv.chula.ac.th>,
  13. Soravut Kruavit <u3642295@chula.edu> wrote:
  14. >Ruud van Gaal (rvg@marketgraph.xs4all.nl) wrote:
  15. >kkl;
  16. >: In <DpE7Ip.7or@unx.sas.com> walker@chang.unx.sas.com (Doug Walker) 
  17. >wrote: : >In article <4k1oce$lub@blackice.winternet.com>,
  18. >: >Anthony Pang <apang@winternet.com> wrote:
  19. >: >>In article <2720tdg60.alamito@marketgraph.xs4all.nl>,
  20. >: >>Ruud van Gaal <rvg@marketgraph.xs4all.nl> wrote:
  21. >: >>>Is there a nice way to get a working alloca() function for the Amiga?
  22. >: >>>It is present on all PC and Unix C implementations, but not on the Amiga.
  23. >: >>>(it allocates mem from the stack, automatically freeing it upon return 
  24. >: from 
  25. >: >>>subroutine).
  26. >: >>
  27. >: >>GCC and SAS have alloca().  I think DICE has it too.
  28. >: >
  29. >: >This is not correct. SAS/C does not supply an alloca() function.
  30. >: >Third parties may have been able to implement one, but it's not
  31. >: >a trivial operation.
  32. >: 
  33. >: Indeed, SAS doesn't have one, but I've received source code for an 
  34. >: implementation which does not free memory upon function exit (would be very 
  35. >: tricky), but somewhere at a later point (garbage collection). It's not really 
  36. >: the ideal thing, but it's close (enough for now).
  37. >: Thanks for all the replies!
  38.  
  39. This approach would definately work.  You could even improve it by using the
  40. PROFILE option and writing "profile functions" that get run when each function
  41. is entered and exited.  The enter function would be a dummy function, and the
  42. exit function would do your garbage collection.  For information on writing
  43. profile functions, see the manual or the source code to the SPROF profiler
  44. in the SC:EXTRAS directory.
  45.  
  46. This is still not a complete alloca() implementation because it doesn't deal
  47. with setjmp/longjmp and you can't alloca() from functions not compiled with
  48. the PROFILE option.
  49.  
  50. -- 
  51.   *****
  52.  *|_o_o|\\     Doug Walker   walker@unx.sas.com
  53.  *|. o.| ||
  54.   | o  |//     Any opinions are mine, not those of
  55.   ======             SouthPeak Interactive
  56.